package com.evil.common.application.enums.permission;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 权限类型
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@AllArgsConstructor
public enum PermissionStatusEnum {

    /**
     * 权限类型
     */
    ALL(0, "全体"),
    ASSIGN(1, "指定"),
    ;

    @Getter
    private final int id;
    @Getter
    private final String name;

    public static Optional<PermissionStatusEnum> findById(Integer id) {
        if (null == id) {
            return Optional.empty();
        }
        return Arrays.stream(values()).filter(e -> e.id == id).findFirst();
    }
}
